package com.zhuiyun.project.api.appuserreport.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.appuser.entity.User;
import com.zhuiyun.project.api.appuserreport.entity.UserReport;
import com.zhuiyun.project.api.appuserreport.mapper.AppUserReportMapper;
import com.zhuiyun.project.api.appuserreport.model.AppUerReportModel;
import com.zhuiyun.project.api.appuserreport.service.AppUserReportService;
import com.zhuiyun.project.api.appuserreport.service.impl.AppUserReportServiceImpl;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.util.constants.CommonConstants;
import com.zhuiyun.project.util.pageUtil.PageRequest;
import com.zhuiyun.project.util.pageUtil.PageResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AppUserController
 * Description T0D0
 * Author Administrator
 * @Date 2023/6/8
 * Version 1.0
 **/

@RestController
@RequestMapping("report")
@CrossOrigin
public class AppUserReportController {

    @Autowired
    AppUserReportService AppUserReportServiceImpl;

    /**
     * 查询被举报用户信息
     *
     * @return com.zhuiyun.project.common.response.CommonResult
     * @author 温
     * @date 2023/7/12 14:32
     * @parameter [reportedUserId, pageRequest]
     */
    @GetMapping("/getUserReportsBy")
    public CommonResult getUserReportsBy(AppUerReportModel appUerReportModel, PageRequest pageRequest) {
        PageResult userReportsBy = AppUserReportServiceImpl.getUserReportsBy(appUerReportModel, pageRequest);
        return CommonResult.ok(userReportsBy);
    }


    /**
     * @param userReport
     * @Author kdj
     * @Description 同意举报申请 类型 1是警告 3是注销
     * @Date 2023/8/14 15:59
     * @Return com.zhuiyun.project.common.response.CommonResult
     */
    @PostMapping("/userReport")
    public CommonResult userReport(@RequestBody UserReport userReport) {
        int i = AppUserReportServiceImpl.userReport(userReport);
        return CommonResult.ok(i);
    }


    /**
     * 用户举报驳回申请
     *
     * @return com.zhuiyun.project.common.response.CommonResult
     * @author 温
     * @date 2023/7/12 14:12
     * @parameter [userReport]
     */
    @PostMapping("/userReportReject")
    public CommonResult userReportReject(@RequestBody UserReport userReport) {
        int i = AppUserReportServiceImpl.userReportReject(userReport);
        return CommonResult.ok(i);
    }


    /**
     * @param userReport
     * @Author kdj
     * @Description 添加举报人记录
     * @Date 2023/8/14 15:49
     * @Return com.zhuiyun.project.common.response.CommonResult
     */
    @PostMapping("/userReportsy")
    public CommonResult getAddReport(@RequestBody UserReport userReport) {
        int i = AppUserReportServiceImpl.userReportsy(userReport);
        if (i > 0) {
            return CommonResult.ok("举报成功");
        } else {
            return CommonResult.error("举报失败");
        }
    }


    /**
     * @Author 小江
     * @Description //TODO 查询举报进度信息
     * @Date 14:39 2023/6/29
     **/
    @GetMapping("userReportList")
    @ApiOperation(value = "查询举报进度信息")
    @OptLog(modular = "查询举报进度信息", type = CommonConstants.SELECT, describe = "查询举报进度信息")
    public CommonResult userReportList(Integer reportingUserId) {
        return AppUserReportServiceImpl.userReportList();
    }


}



